﻿#if ANDROID
using OpenAiMobile.Platforms.Android;
#endif

using System.Diagnostics;

namespace OpenAiMobile.Services
{
    public class PlatformService : IPlatformService
    {
        public async Task<string> GetPhoneNumberAsync()
        {
            var status = await Permissions.CheckStatusAsync<Permissions.Phone>();
            if (status != PermissionStatus.Granted)
            {
                return string.Empty;
            }

            status = await Permissions.CheckStatusAsync<Permissions.Sms>();
            if (status != PermissionStatus.Granted)
            {
                return string.Empty;
            }

            //getLine1NumberForDisplay: Neither user 10242 nor current process has
            //android.permission.READ_PHONE_STATE,
            //android.permission.READ_SMS, or android.permission.READ_PHONE_NUMBERS

#if ANDROID
            return AndroidAppService.GetPhoneNumber();
#else
            return string.Empty;
#endif
        }
    }
}
